package com.example.demo.config;

import com.google.common.base.Predicate;
import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.ApiSelector;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.HashSet;

/**
 * @Author: 朱胜伟
 * @CreateTime: 2020-12-31 13:51
 * @Description:
 */
@EnableSwagger2
@Component
public class swagg {
    @Bean
    public Docket postDocket(){
        Contact contact = new Contact("zsw","http://","274288");

        ApiInfo apiInfo = new ApiInfo("post接口","所有post请求都在这","v1.0","",contact,"","",new HashSet<>());
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .groupName("post扫描")
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(PostMapping.class))
                .build();

        return docket;
    }
    @Bean
    public Docket getDocket(){
        Contact contact = new Contact("zsw","http://","274288");
        ApiInfo apiInfo = new ApiInfo("get接口","所有post请求都在这","v1.0","",contact,"","",new HashSet<>());
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .groupName("get扫描")
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(GetMapping.class))
                .build();
        return docket;
    }
}
